package com.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.EmployeeBean;
import com.project.mapper.IDeptMapper;
import com.project.mapper.IEmployeeMapper;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Title: EmployeeServiceImpl
 * @Package: com.project.service.impl
 * @Description:
 * @Author: Liang-Xie
 * @Date: 2022/7/15 - 16:59
 */
@SuppressWarnings("all")
@Service
@Transactional
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private IDeptMapper DeptMapper;
    @Autowired
    private IEmployeeMapper EmployeeMapper;
    @Override
    public void add(EmployeeBean employeeBean) {
        EmployeeMapper.insert(employeeBean);
    }

    @Override
    public IPage<EmployeeBean> findByItem(Integer pageNO, String deptName, String name) {

        return EmployeeMapper.findByItem(new Page(pageNO,3),deptName,name);
    }

    @Override
    public EmployeeBean findById(Integer id) {
        EmployeeBean em=EmployeeMapper.selectById(id);
        em.setDept(DeptMapper.selectById(em.getDeptId()));
        return em;
    }
}

